{!! Html::style(env("APP_URL").'/assets/backend/libs/webuploader-0.1.5/webuploader.css') !!}


<div class="ibox float-e-margins">
    <div class="ibox-content" style="display: block;">
        <div class="nav-tabs-custom">
            <div class="tab-content">

                <div class="tab-pane active" id="tab_1">
                    <div class="form-group">
                        {!! Form::label('name','导入库存：', ['class' => 'col-md-2 control-label']) !!}
                        <div class="col-md-5">
                            <input type="hidden" name="upload_excel"/>
                            <div id="filePicker">选择文件</div>
                            <p class="update_true"></p>
                            <a no-pjax href="{{url('/assets/template/import_o2o_goods.xlsx')}}" target="_self">商品导入模板下载</a>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                    <div class="well">
                        <div class="pull-left">

                            <button class="btn btn-success add-button" data-toggle="modal-filter"
                                    disabled
                                    data-target="#modal" data-backdrop="static" data-keyboard="false"
                                    data-url="{{route('admin.shop.importStock.importStockModal')}}">
                                执行导入
                            </button>

                        </div>

                        <div class="clearfix"></div>
                    </div>


                </div>
            </div>
        </div>
    </div>
</div>

<div id="modal" class="modal inmodal fade" data-keyboard=false data-backdrop="static"></div>

{!! Html::script(env("APP_URL").'/assets/backend/libs/jquery.form.min.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/libs/webuploader-0.1.5/webuploader.js') !!}

<script>
    $(function () {
        var uploader = WebUploader.create({

            // 选完文件后，是否自动上传。
            auto: true,
            swf: '{{url(env("APP_URL").'/assets/backend/libs/webuploader-0.1.5/Uploader.swf')}}',
            server: '{{route('upload.excel',['_token'=>csrf_token()])}}',
            pick: '#filePicker',
            fileVal: 'upload_excel',
            accept: {
                title: 'Excel',
                extensions: 'xlsx,xlsm,xls'
//                    mimeTypes: 'image/*'
            }
        });
        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
        uploader.on('uploadSuccess', function (file, response) {
            $('.update_true').html("已上传成功请点击执行按钮导入授权码");
            $("input[name='upload_excel']").val(response.file);
            $('.add-button').removeAttr('disabled');
        });
    });

    $(document).on('click.modal.data-api', '[data-toggle="modal-filter"]', function (e) {
        var path = $("input[name='upload_excel']").val();
        var import_type = $("select[name='import_type']").val();

        var $this = $(this),
                href = $this.attr('href'),
                modalUrl = $(this).data('url') + '?path=' + path + '&import_type=' + import_type;

        if (modalUrl) {
            var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, '')));
            $target.modal('show');
            $target.html('').load(modalUrl, function () {

            });
        }
    });
</script>

